﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QD_Clients.Code
{
    public static class WebClientHelper
    {
        /// <summary>
        /// 服务器ip及端口
        /// </summary>
        public static string ServerUri = "http://47.106.217.227:388";

        public class ClientResultDTO
        {
            public bool success { get; set; }
            public object data { get; set; }
        }

        public static ClientResultDTO DownloadString(string uri)
        {
            string url = ServerUri + uri;

            System.Net.WebClient myWebClient = new System.Net.WebClient();
            myWebClient.Encoding = System.Text.Encoding.UTF8;

            string mod = myWebClient.DownloadString(url);

            ClientResultDTO user = JsonConvert.DeserializeObject<ClientResultDTO>(mod);
            return user;
        }
    }
}
